package thread.zjitc.net.lib.share;

/**
 * @author 朱志文
 * @data 2019/11/16 0016
 */
public class MyShareRunnable {
    private volatile float num;
    private volatile boolean flag;

    public void produce(float n){
        while (flag){

        }
        synchronized (this){
            num=n;
            flag=true;
            System.out.println("生产数量为"+num);
        }
    }
    public void custom(){
        while (!flag){

        }
        synchronized (this){
            flag=false;
            System.out.println("销售数量为"+num);
        }
    }
}
